﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using TCKQKL.FrontEnd.Config;
using TCKQKL.FrontEnd.DataModel;
using TCKQKL.Service.LookupClient;

namespace TCKQKL.FrontEnd.Web.Controls
{
    public partial class MarketSummary : System.Web.UI.UserControl
    {
        public string marketName;
        protected void Page_Load(object sender, EventArgs e)
        {
            LSClient client = new LSClient();
            MarketSummaryDataUI market = client.getMaretSummary(marketName);
            client.Close();
            if (market != null)
            {
                if (market.Changed > 0)
                    this.lblIndex.Text = "<div class=\"increase\">" + market.index.ToString("N") + "▲" + market.Changed.ToString("N") + "</div>";
                else
                    if (market.Changed < 0)
                        this.lblIndex.Text = "<div class=\"decrease\">" + market.index.ToString("N") + "▼" + market.Changed.ToString("N") + "</div>";
                    else
                        this.lblIndex.Text = "<div class=\"nochange\">" + market.index.ToString("N") + "(" + market.Changed.ToString("N") + ")</div>";
                this.lblTotalTrade.Text = String.Format("{0:0,0}", market.totalTrade);
                this.lblTotalShare.Text = String.Format("{0:0,0}", market.totalShare);
                this.lblTotalValue.Text = String.Format("{0:0,0}", market.totalValue);
                this.lblMarketStat.Text = market.MarketStat;
                this.lblLastUpdated.Text = market.summaryDate.ToString("dd/MM/yyy");
            }
        }
    }
}